package com.hbase.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;

/**
 * property 文件操作类
 * 
 * @author Zhangwc
 * @since 2016.06.28
 */
public class PropertyFileOpe {
	private static Properties prop = new Properties();
	
	public static Properties loadFiles(String... filePaths) {
		for (int i = 0, j = filePaths.length; i < j; i++) {
			InputStream input = null;
			try {
				input = PropertyFileOpe.class.getClassLoader()
						.getResourceAsStream(filePaths[i]);
				prop.load(input);
			} catch (IOException e) {
				e.printStackTrace();
			} finally {
				if (input != null) {
					try {
						input.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		}
		return prop;
	}

	public static String getProperty(String name) {
		String val = null;
		if(name!=null){
			val = prop.getProperty(name);
		}
		return val;
	}

	public static void main(String[] args) {
		Properties pro = PropertyFileOpe.loadFiles("data-sync.properties");
		String val = pro.getProperty(null);
		System.out.println(val);
	}
}
